#include<bits/stdc++.h>
using namespace std;
int t,n,m,len,V,d[100005],v[100005],a[100005],p[100005];
struct node{int l,r;}sg[100005];
bool cmp(const node &x,const node &y){return x.l!=y.l?x.l<y.l:x.r<y.r;}
int read(){
    char c;
    bool f=0;
    while(1){
        if(isdigit(c=getchar()))break;
        if(c=='-')f=1;
    }
    int res=(c^48);
    while(isdigit(c=getchar()))res=(res<<3)+(res<<1)+(c^48);
    return (f?-res:res);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        n=read(),m=read(),len=read(),V=read();
        for(int i=1;i<=n;i++)d[i]=read(),v[i]=read(),a[i]=read();
        for(int i=1;i<=m;i++)p[i]=read();
        int ans1=0;
        for(int i=1;i<=n;i++){
            int s=lower_bound(p+1,p+m+1,d[i])-p;
            if(a[i]<=0){
                if(s<=m && v[i]*v[i]>=2*(p[s]-d[i])*(-a[i])
                && 2*a[i]*(p[s]-d[i])+v[i]*v[i]>V*V){
                    int l=s,r=m;
                    while(l<r){
                        int mid=(l+r+1)>>1;
                        if(2*a[i]*(p[mid]-d[i])+v[i]*v[i]>V*V)l=mid;
                        else r=mid-1;
                    }sg[++ans1]={s,r};
                }
            }
            else{
                int l=s,r=m+1;
                while(l<r){
                    int mid=(l+r)>>1;
                    if(2*a[i]*(p[mid]-d[i])+v[i]*v[i]>V*V)r=mid;
                    else l=mid+1;
                }
                if(l<=m)sg[++ans1]={l,m};
            }
        }sort(sg+1,sg+ans1+1,cmp);
        int l=sg[1].l,r=sg[1].r,ans2=(ans1>0);
        for(int i=2;i<=ans1;i++){
            l=max(l,sg[i].l),r=min(r,sg[i].r);
            if(l>r)ans2++,l=sg[i].l,r=sg[i].r;
        }
        printf("%d %d\n",ans1,m-ans2);
    }
}
